<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2012.03.17.
   家居公司商铺显示($$)*/

!defined('Q_PATH') && exit;

class ShopController extends InitController{

	public $_arrJiajucompany=array();
	
	public function init__(){
		parent::init__();

		if(!$GLOBALS['_citysitesubsub_']){
			$this->page404();
		}

		// 查询条件
		$arrWhere=array();

		// 判断是vip商铺，还是普通商铺
		if($GLOBALS['_citysitesub_']!='vip'){
			$arrWhere['A.jiajucompany_id']=$GLOBALS['_citysitesubsub_'];
		}else{
			$arrWhere['A.jiajucompany_domain']=$GLOBALS['_citysitesubsub_'];
			$arrWhere['A.jiajucompany_isfvip']=1;
		}

		$arrWhere['A.jiajucompany_status']=1;

		$arrJiajucompany=Model::F_('jiajucompany','@A')
			->setColumns('A.*')
			->join(Q::C('DB_PREFIX').'jiajucompanyvip AS C','C.jiajucompanyvip_music,C.jiajucompanyvip_sinaweibo,C.jiajucompanyvip_qqweibo,C.jiajucompanyvip_kfcode,C.jiajucompanyvip_video,C.jiajucompanyvip_template','A.jiajucompany_id=C.jiajucompany_id')
			->where($arrWhere)
			->getOne();

		if(empty($arrJiajucompany['jiajucompany_id'])){
			$this->page404();
		}

		$GLOBALS['_citysite_']=Core_Extend::getSite_(array('site_id'=>$arrJiajucompany['site_id'],'site_status'=>1));
		if(empty($GLOBALS['_citysite_']['site_id'])){
			$this->page404();
		}
		$GLOBALS['_citysitesub_']=$_GET['D']=$_REQUEST['D']=$GLOBALS['_citysite_']['site_domain'];

		if(in_array(ACTION_NAME,array('index','about'))){
			$arrJiajucompany['jiajucompany_content']=Model::F_('jiajucompanycontent','jiajucompany_id=?',$arrJiajucompany['jiajucompany_id'])->getColumn('jiajucompany_content');
		}

		// 更新点击量
		Model::M_('jiajucompany')->updateWhere(array('jiajucompany_viewnum'=>$arrJiajucompany['jiajucompany_viewnum']+1),'jiajucompany_id=?',$arrJiajucompany['jiajucompany_id']);
		$arrJiajucompany['jiajucompany_viewnum']++;
		
		$this->_arrJiajucompany=$arrJiajucompany;
		$this->assign('arrJiajucompany',$arrJiajucompany);

		// VIP
		if($arrJiajucompany['jiajucompany_isfvip']==1){
			if(!$arrJiajucompany['jiajucompanyvip_template']){
				$arrJiajucompany['jiajucompanyvip_template']='default';
			}

			// 载入缓存
			$arrJiajucompanyBanners=Jiaju_Extend::cacheShopbanner($arrJiajucompany['jiajucompany_id']);
			$this->assign('arrJiajucompanyBanners',$arrJiajucompanyBanners);
		}
	}
	
	public function index(){
		$this->child('Shop@Index','index');
	}

	public function about(){
		$this->child('Shop@About','index');
	}
	
	public function order(){
		$this->child('Shop@Order','index');
	}

	public function map(){
		$this->child('Shop@Map','index');
	}

	public function services(){
		$this->child('Shop@Services','index');
	}
	
	public function contact(){
		$this->child('Shop@Contact','index');
	}
	
	public function honor(){
		$this->child('Shop@Honor','index');
	}

	public function business(){
		$this->child('Shop@Business','index');
	}

	public function comment(){
		$this->child('Shop@Comment','index');
	}
	
	public function addcomment(){
		$this->child('Shop@Addcomment','index');
	}
	
	public function guestbook(){
		$this->child('Shop@Guestbook','index');
	}

	public function addguestbook(){
		$this->child('Shop@Addguestbook','index');
	}

	public function case_(){
		$this->child('Shop@Case','index');
	}
	
	public function case_show(){
		$this->child('Shop@Caseshow','index');
	}

	public function room(){
		$this->child('Shop@Case','index');
	}
	
	public function room_show(){
		$this->child('Shop@Caseshow','index');
	}

	public function video(){
		$this->child('Shop@Video','index');
	}
	
	public function video_show(){
		$this->child('Shop@Videoshow','index');
	}

	public function build(){
		$this->child('Shop@Build','index');
	}
	
	public function build_show(){
		$this->child('Shop@Buildshow','index');
	}
	
	public function package(){
		$this->child('Shop@Package','index');
	}
	
	public function package_show(){
		$this->child('Shop@Packageshow','index');
	}

	public function team(){
		$this->child('Shop@Team','index');
	}
	
	public function team_show(){
		$this->child('Shop@Teamshow','index');
	}
	
	public function event(){
		$this->child('Shop@Event','index');
	}

	public function event_show(){
		$this->child('Shop@Eventshow','index');
	}

	public function anli(){
		$this->child('Shop@Anli','index');
	}

	public function diary(){
		$this->child('Shop@Diary','index');
	}

	public function add_order(){
		$this->child('Shop@Addorder','index');
	}

	public function buildorder(){
		$this->child('Shop@Buildorder','index');
	}

}
